package com.dm.saleassback.categorymanage.controller;

import com.dm.saleassback.categorymanage.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Controller
@Transactional
@CrossOrigin
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    /**
         * @Description 查询类别
         * @Author zhangxue
         * @Date 16:54 2018/5/31
         * @Param
         * @retrun
         **/
    @RequestMapping(value="/queryAllCategory",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> queryAllCategory(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = categoryService.queryAllCategory(param);
        return statusMap;
    }

    /**
         * @Description 新增类别信息
         * @Author zhangxue
         * @Date 15:05 2018/6/1
         * @Param
         * @retrun
         **/
    @RequestMapping(value="/saveCategory",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> saveCategory(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = categoryService.saveCategory(param);
        return statusMap;
    }

    /**
         * @Description 删除类别信息
         * @Author zhangxue
         * @Date 15:06 2018/6/1
         * @Param
         * @retrun
         **/
    @RequestMapping(value="/deleteCategoryById",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> deleteCategoryById(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = categoryService.deleteCategoryById(param);
        return statusMap;
    }

    /**
         * @Description 修改类别信息
         * @Author zhangxue
         * @Date 15:09 2018/6/1
         * @Param
         * @retrun
         **/
    @RequestMapping(value="/updateCategoryById",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> updateCategoryById(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = categoryService.updateCategoryById(param);
        return statusMap;
    }

}
